package com.exam.dao.impl;

import java.util.List;

import org.hibernate.Session;
import org.hibernate.Transaction;

import com.exam.bean.Paper;
import com.exam.dao.PaperDao;
import com.exam.hibernate.HibernateSessionFactory;
import com.exam.util.Page;

public class PaperDaoImpl implements PaperDao {

	public boolean add(Paper obj) throws Exception {
		boolean flag = false;
		Session session = HibernateSessionFactory.getSession();// 获得Session对象
		Transaction transaction = null;// 声明一个事务对象
		try {
			transaction = session.beginTransaction();// 开启事务
			session.save(obj);// 保存信息
			transaction.commit();// 提交事务
			flag = true;
		} catch (Exception ex) {
			ex.printStackTrace();// 需要注释掉
			transaction.rollback();// 事务回滚
		} finally {
			HibernateSessionFactory.closeSession();// 关闭Session对象
		}
		return flag;
	}

	public boolean delete(Integer id) throws Exception {
		// TODO Auto-generated method stub
		return false;
	}

	public boolean delete(List<Integer> idList) throws Exception {
		// TODO Auto-generated method stub
		return false;
	}

	public boolean delete(String strWhere) throws Exception {
		// TODO Auto-generated method stub
		return false;
	}

	public int findCount(String strWhere) throws Exception {
		// TODO Auto-generated method stub
		return 0;
	}

	public List<Paper> findList(String strWhere) throws Exception {
		// TODO Auto-generated method stub
		return null;
	}

	public List<Paper> findListByPage(Page page) throws Exception {
		// TODO Auto-generated method stub
		return null;
	}

	public List<Paper> findListByPage(String strWhere, Page page)
			throws Exception {
		// TODO Auto-generated method stub
		return null;
	}

	public Paper findModel(Integer id) throws Exception {
		// TODO Auto-generated method stub
		return null;
	}

	public boolean update(Paper obj) throws Exception {
		// TODO Auto-generated method stub
		return false;
	}

	public boolean update(List<Paper> objList) throws Exception {
		// TODO Auto-generated method stub
		return false;
	}

}
